package com.kasa.gps.alarm;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.kasa.gps.AlarmActivity;
import com.kasa.gps.tool.Tool;
/**
 * 计划到时提醒
 * */
public class OrderGPSReceiver extends BroadcastReceiver {

	/**BroadcastReceiver 的生命周期不是很长，所以不宜做耗时的事情。*/
	@Override
	public void onReceive(Context context, Intent intent) {
		//振动提醒，要注册android.permission.VIBRATE权限
		Tool.vibrateOn(context);
		//发出闹铃
//		AudioManager audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
//		audioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_ON);
//		audioManager.setRingerMode(AudioManager.MODE_NORMAL);
		Log.i("OrderGPSReceiver", "onReceive...");
		//由于BroadcastReceiver不是一个窗口界面，所以这里不能使用context直接创建对话框。另建一个专门的对话框activity
		Intent alarm = new Intent(context, AlarmActivity.class);
		alarm.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		context.startActivity(alarm);
	}

}
